<?php
namespace App\JsonRpc;
/**
 * This file is part of Hyperf Mall.
 *
 * @link     https://gitee.com/scwlkj/hypref_mall
 * contact  hyperf_mall@163.com
 */
use App\Repository\AddressRepository;
use Hyperf\RpcServer\Annotation\RpcService;
use App\JsonRpc\Interfaces\AddressServiceInterface;

/**
 * @RpcService(name="Member::AddressService", protocol="jsonrpc", server="jsonrpc")
 */
class AddressService extends BaseService implements AddressServiceInterface
{
    public function init()
    {
        $this->repository = AddressRepository::getInstance();
    }

    /**
     * Notes:
     * Author:Jurij.cao
     * Date:2022/7/1
     * @param int $member_id
     * @return array
     */
    public function getAddressListByMemberId(int $member_id): ?array
    {
        return  $this->repository->getAddressListByMemberId($member_id);
    }

    public function getAddress(int $member_id, int $id = 0): ?array
    {
        return  $this->repository->getAddress( $member_id, $id);
    }

    /**
     * Notes: 增加收货地址 - pc用
     * Author: Bruce.z
     * DateTime: 2022/10/18 11:02
     * @param int $member_id
     * @param array $param
     * @return mixed
     */
    public function createByPc(int $member_id, array $param)
    {
        return  $this->repository->createByPc( $member_id, $param);
    }

    /**
     * Notes: 设置默认收货地址
     * Author: Bruce.z
     * DateTime: 2022/10/19 10:28
     * @param int $member_id
     * @param int $id
     * @return bool
     */
    public function setDefault(int $member_id, int $id):bool
    {
        return  $this->repository->setDefault($member_id, $id);
    }

}
